{layout name="common/layout" /}
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>
<style>
	.editer{
		margin-left: 0px;
	}
	input {
		font-size: 14px;
		color: #222;
		margin: -5px 0 0 10px;
		outline: none;
		border: none;
	}
	.lab{
		margin-left: 60px;;
	}
</style>
<div class="Hui-article-box" style="margin-top: 37px;">
	<div class="breadcrumb"><i class="Hui-iconfont"></i> <a href="index.html" class="maincolor">首页</a> 
		<span class="c-999 en">&gt;</span>
	</div>
	<div class="Hui-article">
		<div class="jiesuan">
			<div class="recond-titles">
				<h3 style="margin:10px 0 10px 16px;font-size: 18px;">结算单</h3>
			</div>
			<div class="jie-text">
				<form id="frm" method="post" enctype="multipart/form-data" style="border:0;"  class="form-horizontal" action="{:url('order/jiesuan_add')}">
					<input type="hidden" name="settlement_bill_order_id" value="{$data.order_list.order_id}" />
					<input type="hidden" name="settlement_bill_goods_id" value="{$data.order_list.order_goods_id}" />
					<input type="hidden" name="settlement_bill_merchant_id" value="{$data.order_list.order_merchant_id}" />
					<input type="hidden" name="settlement_bill_rent" value="{$data.order_list.order_rent_money*$data.order_list.goods_amount}" />
					<input type="hidden" name="pay_price" value="{$data.order_list.pay_price}" />
					<input type="hidden" name="actual_rent_total" value="{$data.order_list.actual_rent_total}" />
					<input id="ipt_order_deposit" value="{$data.order_list.order_deposit}" name="order_deposit" type="hidden" style="margin-top: 0px;width: 300px;height: 30px;border:1px solid #e8e8e8;float: left;margin-left: 36px;border-radius: 6px;text-align: right; " readonly="readonly" />
					<div class="cl" style="margin-bottom: 20px;">
						<p style="float: left;font-size:20px;color:#000;margin-left: 80px;">
							&nbsp;&nbsp;
								消费者订单实付款：</p><p id="total_price" style="float: left;color:red;font-size:20px;">
						￥{$data.order_list.pay_price}</p><p style="float: left;font-size:20px;color:#000;">(
							总租金:￥{$data.order_list.actual_rent_total|sprintf ="%.2f",###}、
						    总押金:￥{$data.order_list.order_deposit|sprintf ="%.2f",###}、
						    总运费:￥{$data.order_list.order_freight|sprintf ="%.2f",###})
						</p>
					</div>
				    <div class="lab cl">
						<div class="lab-l">
							<span class="span">实际租金：</span>
						</div>
						<div class="lab-r" style="width: 300px;height: 30px;border:1px solid #e8e8e8;margin-top: 5px;border-radius: 6px;text-align: right;">
							￥{$data.order_list.order_total_price|sprintf ="%.2f",###}
						</div>
						<label style="position:relative;top: 10px;">
						{if condition="$data.order_list.order_activity_id gt '0'"}
						&nbsp;&nbsp;(活动折扣{$data.order_list.market_rate}%)
						{/if}
						</label>
					</div>
					<div class="lab cl">
						<div class="lab-l">
							<span class="span">续租租金：</span>
						</div>
						<div class="lab-r" style="width: 300px;height: 30px;border:1px solid #e8e8e8;margin-top: 5px;border-radius: 6px;text-align: right;">
							￥{$data.order_list.relet_rent_price|sprintf ="%.2f",###}</div>
					</div>
					<div class="lab cl">
						<div class="lab-l">
							<span class="span" style="font-weight:bold;">合计租金：</span>
						</div>
						<div class="lab-r" style="font-weight:bold;width: 300px;height: 30px;border:1px solid #e8e8e8;margin-top: 5px;border-radius: 6px;text-align: right;">
							￥{$data.order_list.order_total_price+$data.order_list.relet_rent_price|sprintf ="%.2f",###}</div>
					</div>
                    <div class="lab cl">
						<div class="lab-l">
							<span class="span">平台优惠券：</span>
						</div>
						<div id="pt_coupon" class="lab-r" style="width: 300px;height: 30px;border:1px solid #e8e8e8;margin-top: 5px;border-radius: 6px;text-align: right;">
							￥{$data.order_list.coupon_amount|sprintf ="%.2f",###}</div>
					</div>
					<div class="lab cl">
						<div class="lab-l">
							<span class="span">店铺优惠券：</span>
						</div>
						<div id="dp_coupon" class="lab-r" style="width: 300px;height: 30px;border:1px solid #e8e8e8;margin-top: 5px;border-radius: 6px;text-align: right;">
							￥{$data.order_list.store_coupon_amount|sprintf ="%.2f",###}
					     </div>
					</div>
					<div class="lab cl">
							<div class="lab-l">
								<span class="span">违约金：</span>
							</div>
							<div class="lab-r" style="border:0;margin-top: 5px;">
								<input onpropertychange="adds()" oninput="adds()" type="text" name="settlement_bill_liquidated" class="input-text radius size-M breaks" style="margin-bottom: 0;margin-top: 0;text-align: right;margin-left: 0px;" placeholder="+-￥0.00"><br>
							</div>
						</div>
					<div class="lab cl">
							<div class="lab-l">
								<span class="span">损坏赔偿金：</span>
							</div>
							<div class="lab-r" style="border:0;margin-top: 5px;">
								<input type="text" onpropertychange="adds()" oninput="adds()" name="settlement_bill_damages" class="input-text radius size-M lose" placeholder="￥0.00" style="text-align: right;margin-top: -4px;margin-left: 0px;"><br>
							</div>
						</div>

					<div class="lab cl">
						<div class="lab-l">
							<span class="span">运费：</span>
						</div>
						<div style="width: 300px;height: 30px;border:1px solid #e8e8e8;float: left;border-radius: 6px;text-align: right;margin-left: 0px;" class="fare">
							￥{$data.order_list.order_freight|sprintf ="%.2f",###}
						</div>
					</div>

					<div class="lab cl">
						<div class="lab-l">
							<span class="span">小计：</span>
						</div>
						<div class="lab-r" style="border:0;margin-top: 5px;">
							<input type="text" class="total" name="settlement_bill_total" style="margin-top: 0px;margin-left: 0px;width: 300px;height: 30px;border:1px solid #e8e8e8;float: left;border-radius: 6px;text-align: right; " readonly="readonly">

						</div>
					</div>
					<div class="lab cl">
						<div class="lab-l">
							<span class="span">实际退款金额：</span>
						</div>
						<div class="lab-r" style="border:0;margin-top: 5px;">
							<input type="text" class="actual_total" style="margin-top: 0px;width: 300px;height: 30px;border:1px solid #e8e8e8;float: left;margin-left: 0px;border-radius: 6px;text-align: right; " readonly="readonly">

						</div>
					</div>
					<div class="lab cl">
						<div class="lab-l">
							<span class="span">备注：</span>
						</div>
						<div class="lab-r" style="border:0;margin-top: 5px;">
							<input type="text" name="settlement_bill_remarks" class="input-text radius size-XL" placeholder="请备注违约金 损坏赔偿金产生的原因" style="font-size: 12px;margin-left: 0px">
						</div>
					</div>
                   <button class="box-btn btn1" type="button" onClick="save();">确认</button>
					<button class="box-btn btn1"  style="margin-top: -40px;margin-left: 440px;" type="button" onclick="history.go(-1)">取消</button>
				</form>
			</div>
		</div>
	</div>			
</div>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/hui/static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="__MERCHANT_STATIC__/style/js/page.js"></script>
<script>
	adds();
	function adds(){
		var rent=$("input[name='actual_rent_total']").val();//总租金
        var breaks=$('.breaks').val();
		var lose=$('.lose').val();
		var fare=$('.fare').html().split('￥')[1];
		var s1=parseFloat(rent);
		var total = '';
		 
		 
		if(breaks== '' && lose!=''){
			total=s1*10+parseFloat(fare)*10+parseFloat(lose)*10;
		}else if(lose=='' && breaks!=''){
			lose='0';
			total=s1*10+parseFloat(fare)*10+parseFloat(breaks)*10;
		}else if(lose=='' && breaks==''){
			lose='0';
			total=s1*10+parseFloat(fare)*10;
		}else{
			total=s1*10+parseFloat(breaks)*10+parseFloat(fare)*10+parseFloat(lose)*10;
		}
		total = ((total)/10).toFixed(2);
        $('.total').val(total);
	
        var total_price = $("#total_price").html().split('￥')[1];




        $('.actual_total').val((total_price-total).toFixed(2));


		 
	}
	
function save()
{

	 var total = parseFloat( $("input[name='settlement_bill_total']").val());
     if(total<0)
	 {
	   layer.msg("结算小计金额不能小于0!");
	   return;
	 }
     var c_total = parseFloat("{$data.order_list.pay_price}");
     if(total > c_total )
	 {
	   layer.msg("结算小计金额不能大于实付款！");
	   return;
	 }

	var stype = '';
    var type = "{$data.type}";
    if (type){
        stype = '?type=' + parseInt(type);
    }

     $.ajax({
          type: "POST",
          url: "<?php echo url('order/jiesuan_add', '', false); ?>",
          dataType: 'json',
          cache: false,
          data: $('#frm').serialize(),
          success: function(data) {
            if(data.status == 1) 
            {
			 layer.msg("结算成功!");
			 location.href="{:url('order/index')}" + stype;
			 }else{
              layer.msg(data.msg);
            }

          },
          error: function(xhr, status, error) {
            console.log(xhr);
            console.log(status);
            console.log(error);
          }
        });
	 
}
	
	
</script>
